Skip to content

Conversation

shaneahmed
Copy link
Member

@shaneahmed shaneahmed commented Sep 20, 2024

Summary of Changes

Major Additions

  • Dask Integration:

    • Added dask as a dependency and integrated Dask arrays and lazy computation throughout the engine and patch predictor code.
    • Added Dask-based merging, chunking, and memory-aware processing for large images and WSIs.
  • Zarr Output Support:

    • Added support for saving model predictions and intermediate results directly to Zarr format.
    • New CLI options and internal logic for Zarr output, including memory thresholding and chunked writes.
  • SemanticSegmentor Engine:

    • Added a new SemanticSegmentor engine with Dask/Zarr support and new test coverage (test_semantic_segmentor.py).
    • Added CLI entrypoint for semantic_segmentor and removed the old semantic_segment CLI.
  • Enhanced CLI and Config:

    • Added CLI options for memory threshold, unified worker options, and improved mask handling.
    • Updated YAML configs and sample data for new models and test images.
  • Utilities and Validation:

    • Added utility functions for minimal dtype casting, patch/stride validation, and improved error handling (e.g., DimensionMismatchError).
    • Improved annotation store conversion for Dask arrays and Zarr-backed outputs.
  • Changes to kwarg

    • Add memory-threshold
    • Unified num-loader-workers and num-postproc-workers into num-workers
    • Removed cache_mode as cache mode is automatically handled.

Major Removals/Refactors

  • Removed Old CLI and Redundant Code:

    • Deleted the old semantic_segment.py CLI and replaced it with semantic_segmentor.py.
    • Removed legacy cache mode and patch prediction Zarr store tests.
  • Refactored Model and Dataset APIs:

    • Unified and simplified model inference APIs to always return arrays (not dicts) for batch outputs.
    • Refactored dataset classes to enforce patch shape validation and remove legacy “mode” logic.
  • Test Cleanup:

    • Removed or updated tests that relied on old APIs or cache mode.
    • Refactored test assertions for new output types and Dask array handling.
  • API Consistency:

    • Standardized function and argument names across engines, CLI, and utility modules.
    • Updated docstrings and type hints for clarity and consistency.

Notable File Changes

  • New:

    • tiatoolbox/cli/semantic_segmentor.py
    • tests/engines/test_semantic_segmentor.py
  • Removed:

    • tiatoolbox/cli/semantic_segment.py
    • Old cache mode and patch Zarr store tests
  • Heavily Modified:

    • engine_abc.py, patch_predictor.py, semantic_segmentor.py
    • CLI modules and test suites
    • Dataset and utility modules for Dask/Zarr compatibility

Impact

  • Enables scalable, parallel, and memory-efficient inference and output saving for large images.
  • Simplifies downstream analysis by supporting Zarr as a native output format.
  • Lays the groundwork for further Dask-based optimizations in TIAToolbox.

@shaneahmed shaneahmed self-assigned this Sep 20, 2024
@shaneahmed shaneahmed added the enhancement New feature or request label Sep 20, 2024
@shaneahmed shaneahmed added this to the Release v2.0.0 milestone Sep 20, 2024
@codecov
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.72%. Comparing base (31b7995) to head (19b404b).
⚠️ Report is 1 commits behind head on dev-define-engines-abc.

Additional details and impacted files
@@                    Coverage Diff                     @@
##           dev-define-engines-abc     #866      +/-   ##
==========================================================
+ Coverage                   91.33%   94.72%   +3.38%     
==========================================================
  Files                          73       73              
  Lines                        9375     9235     -140     
  Branches                     1229     1208      -21     
==========================================================
+ Hits                         8563     8748     +185     
+ Misses                        776      452     -324     
+ Partials                       36       35       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@shaneahmed shaneahmed marked this pull request as draft February 5, 2025 16:27
- Use `input_resolutions` instead of resolution to make engines outputs compatible with ioconfig.
- Uses input resolution as a list of dictionaries on units and resolution.
- Use `input_resolutions` instead of resolution to make engines outputs compatible with ioconfig.
- Uses input resolution as a list of dictionaries on units and resolution.
…mentor

# Conflicts:
#	tests/engines/test_engine_abc.py
#	tests/engines/test_patch_predictor.py
#	tiatoolbox/models/engine/engine_abc.py
#	tiatoolbox/models/engine/io_config.py
#	tiatoolbox/models/engine/patch_predictor.py
@adamshephard adamshephard self-requested a review September 12, 2025 09:39
Copy link
Collaborator

@measty measty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done an initial review, looks nice overall but I found a few issues that need addressing before it could be merged.

@shaneahmed shaneahmed linked an issue Oct 3, 2025 that may be closed by this pull request
@shaneahmed shaneahmed force-pushed the dev-define-semantic-segmentor branch from fe21c69 to 3a47fe1 Compare October 16, 2025 16:12
@shaneahmed shaneahmed merged commit b542c9a into dev-define-engines-abc Oct 20, 2025
39 checks passed
@shaneahmed shaneahmed deleted the dev-define-semantic-segmentor branch October 20, 2025 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shifted patches when merging patch predictions!

3 participants